const db = require('../config/db')
const {DataTypes} = require('sequelize');
const attributes = {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,            // 主键
        autoIncrement: true,// 自动递增
        comment: '留言id',
    },
    name: {
        type: DataTypes.STRING(18),
        comment: '留言者名称',
        allowNull: false
    },
    number: {
        type: DataTypes.STRING(11),
        comment: '留言者账号',
        allowNull: false
    },
    message: {
        type: DataTypes.STRING,
        comment: '留言内容',
        allowNull: false
    },
    reply_time: {
        type: DataTypes.INTEGER,
        comment: '回复次数',
        allowNull: true,
        default: 0
    },
    reply_message_id: {
        type: DataTypes.STRING,
        comment: '回复留言的id,如果不说回复留言，该值为null',
        allowNull: true
    },
}


const blogMessageBoardModel = db.define('message_board', attributes)


// blogMessageBoardModel.sync({alter: true})

module.exports = blogMessageBoardModel
